
package com.wujilee.dbredissyn.config;

import com.wujilee.dbredissyn.common.ServiceResult;
import com.wujilee.dbredissyn.exception.BusinessException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理器
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public ServiceResult<?> handleBusinessException(BusinessException e) {
        return new ServiceResult<>(false, 500, e.getMessage());
    }

}
